<template>
  <van-row class="page-assess-dept-list">
    <van-nav-bar
      left-text="返回"
      right-text="确定"
      title="申请单位"
      @click-left="$emit('onCancel')"
      @click-right="doConfirm"/>
    <van-radio-group v-model="selectedDept">
      <van-cell-group>
        <card-apply-dept
          v-for="(depart) in departments"
          :key="depart.department_path"
          :department="depart"
          @onClick="selectedDept = depart"/>
      </van-cell-group>
    </van-radio-group>
  </van-row>
</template>

<script>
import CardApplyDept from '@/views/common/card/CardApplyDept'
export default {
  name: 'PageApplyDeptList',
  components: { CardApplyDept },
  props: ['assessType'],
  data () {
    return {
      departments: this.assessType === (this.$vo.AssessType.CORP + '') ? this.$store.state.authInfo.user.roles.corp.dept : this.$store.state.authInfo.user.roles.dept.dept,
      selectedDept: null
    }
  },
  methods: {
    doConfirm () {
      if (this.selectedDept === null) {
        this.$dialog.alert({
          message: '请选择申请部门'
        })
        return
      }
      this.$emit('onConfirm', this.selectedDept.department_path)
    }
  }
}
</script>

<style scoped lang="less">

</style>
